<html>
<head>
    <meta charset="x-UTF-16LE-BOM">
    <title>在表格中输出圆的周长和面积</title>
</head>
<body>
<form method="post" action="案例：在表格中输出圆的周长和面积.php">
    <tr>
        <td><label for="r">请输入圆的半径：</label></td>
        <input type="text" name="r" value="5"/>
        <input type="submit" name="submit" value="计算">
    </tr>
</form>

</body>
</html>
<?php
error_reporting(0);
define("PI", 3.14);
$r = $_POST["r"];
$s = getS($r);
$c = getC($r);
echo "<table border='10'>
<tr>
<th>计算圆的面积</th>
</tr>
<tr>
<td>圆的半径：$r</td>
</tr>
<tr>
<td>圆形的面积为.$s.</td>
</tr>
<tr>
<td>圆形的周长为.$c.</td>
</tr>
</table>";
echo "<Br><hr/><br>";

function getS($raduis)
{
    $area = PI * $raduis * $raduis;
    return $area;
}

function getC($raduis)
{
    $perimeter = PI * 2 * $raduis;
    return $perimeter;
}

?>

